<template>
  <div style="width: 100%;height:100%">
    <welthree
      :bonustol="(UserInfo.message+UserInfo.bonus_points)/10000"
      :rechargetol="UserInfo.message/10000"
      :deletol="UserInfo.bonus_points/10000"
      :priceList="priceList"
    >
    </welthree>
  </div>
</template>

<script>
import Request from "../commons/Request"
import welthree from "../views/welcome/welthree.vue"
import { mapGetters } from "vuex";
export default {
  name: "welcome",
  components:{welthree},
  data() {
    return {
      date:new Date,
      month:new Date,
      firstDay:'',
      lastDay:'',
      show:2,
      msg: "Welcome to 管理平台",
      list:[],
      bonus:[],
      recharge:[],
      bonustol:'',
      rechargetol:'',
      deletol:'',
      points:'',
      ftotal:'',
      mbonustol:'',
      mrechargetol:'',
      mdeletol:'',   
      priceList:[],
      totalCnt:0,
      wsskt:require('../assets/images/peach-svg/homepage/wsskt.svg'),
      amazon:require('../assets/images/peach-svg/homepage/amazon.svg'),
      fb:require('../assets/images/peach-svg/homepage/fb.svg'),
      ins:require('../assets/images/peach-svg/homepage/ins.svg'),
      lin:require('../assets/images/peach-svg/homepage/lin.svg'),
      viber:require('../assets/images/peach-svg/homepage/viber.svg'),
      line:require('../assets/images/peach-svg/homepage/line.svg'),
      zalo:require('../assets/images/peach-svg/homepage/zalo.svg'),
      twitter:require('../assets/images/peach-svg/homepage/twitter.svg'),
      skype:require('../assets/images/peach-svg/homepage/skype.svg'),
      tg:require('../assets/images/peach-svg/homepage/tg.svg'),
      momo:require('../assets/images/peach-svg/homepage/momo.svg'),
      weiruan:require('../assets/images/peach-svg/homepage/weiruan.svg'),
      truem:require('../assets/images/peach-svg/homepage/truem.svg'),
      botim:require('../assets/images/peach-svg/homepage/botim.svg'),
      mtn:require('../assets/images/peach-svg/homepage/mtn.svg'),
      gaoji:require('../assets/images/peach-svg/homepage/yunyings.svg'),
      biaozhun:require('../assets/images/peach-svg/homepage/yunyings.svg'),
      konghao:require('../assets/images/peach-svg/homepage/konghao.svg'),
      tiktok:require('../assets/images/peach-svg/homepage/tiktok.svg'),
    };
  },
  computed:{ 
    ...mapGetters(["UserInfo"]),
  },
  methods: {
    async initView() {
      this.$store.dispatch("RequestSysDefine",true);
      await this.getList();
    },
    async getList(){

      // 图片对象
      const imageMap = {
        'ws筛活跃': this.wsskt,
        'ws筛性别': this.wsskt,
        'ws筛有效': this.wsskt,
        'Viber筛有效': this.viber,
        'Viber筛活跃': this.viber,
        'FB筛有效': this.fb,
        '领英筛有效': this.lin,
        'amazon筛有效': this.amazon,
        "INS筛有效":this.ins,
        'microsoft筛有效': this.weiruan,
        'tg筛活跃': this.tg,
        'zalo筛性别': this.zalo,
        'botim筛有效': this.botim,
        'line筛性别': this.line,
        'tg筛有效': this.tg,
        'skype筛有效': this.skype,
        'trueMoney筛有效': this.truem,
        'zalo筛有效': this.zalo,
        'momo筛有效': this.momo,
        'mtnMomo筛有效': this.mtn,
        'twitter筛有效': this.twitter,
        'line筛有效': this.line,
        '运营商高级筛': this.gaoji,
        '运营商标准筛': this.biaozhun,
        '空号检测':this.konghao,
        '领英标准筛':this.lin,
        '领英高级筛': this.lin,
        'TK筛有效':this.tiktok,
        'TK格式筛':this.tiktok,
      };

      let res4 = await Request.post("exclude", "GetBusinessType");
      if(res4.code==0 && res4.data.list != null){
        res4.data.list.forEach(element => {
          const imgg = imageMap[element.desc] || null;
        let unit_price = element.unit_price/10000;
        let formattedNumber=""
          // number 为需要格式化的数字
        if (Number.isInteger(unit_price)) {
          // 如果是整数，保留整数
          formattedNumber = Math.trunc(unit_price);
        } else {
          // 如果是小数，保留小数点后五位
          formattedNumber = parseFloat(unit_price.toFixed(4));
        }
          this.priceList.push({"id":element.desc,"name":formattedNumber,"img":imgg})
        });
      }
      
    },    
  },
};
</script>
